package com.youxin.cpcenter.controller;

import com.youxin.busfoundation.bean.ResponseObject;
import com.youxin.busfoundation.bean.ent.RequestEntIdentifyInfo;
import com.youxin.busfoundation.bean.ent.RequestMemberInfo;
import com.youxin.cpcenter.common.log.LogMethod;
import com.youxin.cpcenter.model.TbMemberInfo;
import com.youxin.cpcenter.service.TestService;
import com.youxin.foundation.utils.ObjectUtils;
import com.youxin.foundation.utils.RegexUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 会员管理 企业认证接口
 * 
 * @author yingde.cao
 *
 */
@RestController
public class TestController extends BaseController{
	
	@Autowired
	private TestService testService;

	@RequestMapping(value = "/api/test", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseObject test(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,@RequestBody RequestEntIdentifyInfo bean) {
		try {
			ObjectUtils.requestNonEmpty(bean.getCompanyUid(), "企业id不能为空");
			ObjectUtils.requestNonEmpty(bean.getFullName(), "企业名称不能为空");
			ObjectUtils.requestNonEmpty(bean.getMemberUid(), "会员uid不能为空");
			return testService.requestIdentify(bean);
		} catch (DuplicateKeyException e) {
			logger.error("/identify企业认证错误:", e);
			return ResponseObject.userFailure("当前企业已经被认证");
		} catch (Exception e) {
			logger.error("/identify企业认证错误:", e);
			return ResponseObject.systemError(e);
		}
	}

}
